// manifest.config.ts
import { defineManifestConfig } from '@uni-helper/vite-plugin-uni-manifest'
import path from 'node:path'
import { loadEnv } from 'vite'

// 获取环境变量的范例
const env = loadEnv(process.env.NODE_ENV!, path.resolve(process.cwd(), 'env'))
const {
  VITE_APP_TITLE,
  VITE_UNI_APPID,
  VITE_WX_APPID,
  VITE_APP_PUBLIC_BASE,
  VITE_FALLBACK_LOCALE,
} = env

export default defineManifestConfig({
  name: VITE_APP_TITLE,
  appid: VITE_UNI_APPID,
  description: '',
  versionName: '1.0.6',
  versionCode: '106',
  transformPx: false,
  locale: VITE_FALLBACK_LOCALE, // 'zh-Hans'
  h5: {
    router: {
      base: VITE_APP_PUBLIC_BASE,
    },
  },
  /* 5+App特有相关 */
  'app-plus': {
    usingComponents: true,
    nvueStyleCompiler: 'uni-app',
    compilerVersion: 3,
    compatible: {
      ignoreVersion: true,
    },
    splashscreen: {
      alwaysShowBeforeRender: true,
      waiting: true,
      autoclose: true,
      delay: 0,
    },
    /* 模块配置 */
    modules: {},
    /* 应用发布信息 */
    distribute: {
      /* android打包配置 */
      android: {
        minSdkVersion: 21,
        targetSdkVersion: 30,
        abiFilters: ['armeabi-v7a', 'arm64-v8a'],
        permissions: [
          '<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>',
          '<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>',
          '<uses-permission android:name="android.permission.VIBRATE"/>',
          '<uses-permission android:name="android.permission.READ_LOGS"/>',
          '<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>',
          '<uses-feature android:name="android.hardware.camera.autofocus"/>',
          '<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>',
          '<uses-permission android:name="android.permission.CAMERA"/>',
          '<uses-permission android:name="android.permission.GET_ACCOUNTS"/>',
          '<uses-permission android:name="android.permission.READ_PHONE_STATE"/>',
          '<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>',
          '<uses-permission android:name="android.permission.WAKE_LOCK"/>',
          '<uses-permission android:name="android.permission.FLASHLIGHT"/>',
          '<uses-feature android:name="android.hardware.camera"/>',
          '<uses-permission android:name="android.permission.WRITE_SETTINGS"/>',

          '<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>',
          '<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>',
          '<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>',
          '<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>',
          '<uses-permission android:name="android.permission.READ_MEDIA_VIDEO"/>',
          '<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>',
          '<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED"/>',
        ],
      },
      /* ios打包配置 */
      ios: {},
      /* SDK配置 */
      sdkConfigs: {},
      /* 图标配置 */
      icons: {
        android: {
          hdpi: 'src/static/app/icons/72x72.png',
          xhdpi: 'src/static/app/icons/96x96.png',
          xxhdpi: 'src/static/app/icons/144x144.png',
          xxxhdpi: 'src/static/app/icons/192x192.png',
        },
        ios: {
          appstore: 'src/static/app/icons/1024x1024.png',
          ipad: {
            app: 'src/static/app/icons/76x76.png',
            'app@2x': 'src/static/app/icons/152x152.png',
            notification: 'src/static/app/icons/20x20.png',
            'notification@2x': 'src/static/app/icons/40x40.png',
            'proapp@2x': 'src/static/app/icons/167x167.png',
            settings: 'src/static/app/icons/29x29.png',
            'settings@2x': 'src/static/app/icons/58x58.png',
            spotlight: 'src/static/app/icons/40x40.png',
            'spotlight@2x': 'src/static/app/icons/80x80.png',
          },
          iphone: {
            'app@2x': 'src/static/app/icons/120x120.png',
            'app@3x': 'src/static/app/icons/180x180.png',
            'notification@2x': 'src/static/app/icons/40x40.png',
            'notification@3x': 'src/static/app/icons/60x60.png',
            'settings@2x': 'src/static/app/icons/58x58.png',
            'settings@3x': 'src/static/app/icons/87x87.png',
            'spotlight@2x': 'src/static/app/icons/80x80.png',
            'spotlight@3x': 'src/static/app/icons/120x120.png',
          },
        },
      },
    },
    nativePlugins: {
      'JG-JPush': {
        JPUSH_XIAOMI_APPKEY: 'MI-5832023392753',
        JPUSH_MEIZU_APPID: 'MZ-145227',
        JPUSH_OPPO_APPSECRET: 'OP-51979c2c14994556902c63ff3b0d7620',
        JPUSH_OPPO_APPKEY: 'OP-de47acb7b1914909bd48d9b92ea6cc8f',
        JPUSH_ADVERTISINGID_IOS: '',
        JPUSH_MEIZU_APPKEY: 'MZ-3bc771b4624d43c2a0e2a25ce605e7c1',
        JPUSH_OPPO_APPID: 'OP-30679073',
        JPUSH_DEFAULTINITJPUSH_IOS: '',
        JPUSH_VIVO_APPKEY: '711f64a91b14bc5962381995ded1709a',
        JPUSH_VIVO_APPID: '105522482',
        JPUSH_ISPRODUCTION_IOS: '',
        JPUSH_XIAOMI_APPID: 'MI-2882303761520233753',
        JPUSH_HUAWEI_APPID: 'appid=108041217',
        JPUSH_HONOR_APPID: '220320187',
        JPUSH_GOOGLE_API_KEY: 'g-AIzaSyDu7ySYWOPSh_kBqYiIbeliIP7qFX1EcfA',
        JPUSH_GOOGLE_APP_ID: 'g-1:1081961039094:android:e1f27831a01dd7a1ec18d7',
        JPUSH_GOOGLE_PROJECT_NUMBER: 'g-1081961039094',
        JPUSH_GOOGLE_PROJECT_ID: 'g-jiguang-demo-57611',
        JPUSH_GOOGLE_STORAGE_BUCKET: 'g-jiguang-demo-57611.appspot.com',
        __plugin_info__: {
          name: 'JG-JPush',
          description: '极光推送Hbuilder插件',
          platforms: 'Android,iOS',
          url: '',
          android_package_name: '',
          ios_bundle_id: '',
          isCloud: false,
          bought: -1,
          pid: '',
          parameters: {
            JPUSH_XIAOMI_APPKEY: {
              des: '厂商 xiaomi appKey,示例：MI-12345678',
              key: 'XIAOMI_APPKEY',
              value: '',
            },
            JPUSH_MEIZU_APPID: {
              des: '厂商 meizu appId,示例：MZ-12345678',
              key: 'MEIZU_APPID',
              value: '',
            },
            JPUSH_OPPO_APPSECRET: {
              des: '厂商 oppo appSecret,示例：OP-12345678',
              key: 'OPPO_APPSECRET',
              value: '',
            },
            JPUSH_OPPO_APPKEY: {
              des: '厂商 oppo appkey,示例：OP-12345678',
              key: 'OPPO_APPKEY',
              value: '',
            },
            JPUSH_ADVERTISINGID_IOS: {
              des: '[iOS]广告标识符（IDFA） 如果不需要使用IDFA，可不填',
              key: 'JPush:ADVERTISINGID',
              value: '',
            },
            JPUSH_MEIZU_APPKEY: {
              des: '厂商 meizu appKey,示例：MZ-12345678',
              key: 'MEIZU_APPKEY',
              value: '',
            },
            JPUSH_OPPO_APPID: {
              des: '厂商 oppo appId,示例：OP-12345678',
              key: 'OPPO_APPID',
              value: '',
            },
            JPUSH_DEFAULTINITJPUSH_IOS: {
              des: '[iOS]是否默认初始化，是填true，不是填false或者不填',
              key: 'JPush:DEFAULTINITJPUSH',
              value: '',
            },
            JPUSH_VIVO_APPKEY: {
              des: '厂商 vivo appkey,示例：12345678',
              key: 'com.vivo.push.api_key',
              value: '',
            },
            JPUSH_VIVO_APPID: {
              des: '厂商 vivo appId,示例：12345678',
              key: 'com.vivo.push.app_id',
              value: '',
            },
            JPUSH_ISPRODUCTION_IOS: {
              des: '[iOS]是否是生产环境，是填true,不是填false或者不填',
              key: 'JPush:ISPRODUCTION',
              value: '',
            },
            JPUSH_XIAOMI_APPID: {
              des: '厂商 xiaomi appId,示例：MI-12345678',
              key: 'XIAOMI_APPID',
              value: '',
            },
            JPUSH_HUAWEI_APPID: {
              des: '厂商HUAWEI-appId,示例：appid=12346578',
              key: 'com.huawei.hms.client.appid',
              value: '',
            },
            JPUSH_HONOR_APPID: {
              des: '厂商HONOR-appId,示例：12346578',
              key: 'com.hihonor.push.app_id',
              value: '',
            },
            JPUSH_GOOGLE_API_KEY: {
              des: '厂商google api_key,示例:g-12346578',
              key: 'google_api_key',
              value: '',
            },
            JPUSH_GOOGLE_APP_ID: {
              des: '厂商google mobilesdk_app_id,示例：g-12346578',
              key: 'google_app_id',
              value: '',
            },
            JPUSH_GOOGLE_PROJECT_NUMBER: {
              des: '厂商google project_number,示例：g-12346578',
              key: 'gcm_defaultSenderId',
              value: '',
            },
            JPUSH_GOOGLE_PROJECT_ID: {
              des: '厂商google project_id ,示例：g-12346578',
              key: 'project_id',
              value: '',
            },
            JPUSH_GOOGLE_STORAGE_BUCKET: {
              des: '厂商google storage_bucket,示例：g-12346578',
              key: 'google_storage_bucket',
              value: '',
            },
          },
        },
      },
      'JG-JCore': {
        JPUSH_APPKEY_ANDROID: 'd2047a1276a198975d44b914',
        JPUSH_APPKEY_IOS: 'd2047a1276a198975d44b914',
        JPUSH_CHANNEL_ANDROID: '',
        JPUSH_CHANNEL_IOS: '',
        __plugin_info__: {
          name: '极光推送 JCore 官方 SDK',
          description: '极光推送 JCore 官方 SDK HBuilder 插件版本',
          platforms: 'Android,iOS',
          url: 'https://ext.dcloud.net.cn/plugin?id=4028',
          android_package_name: '',
          ios_bundle_id: '',
          isCloud: true,
          bought: 1,
          pid: '4028',
          parameters: {
            JPUSH_APPKEY_ANDROID: {
              des: '[Android]极光portal配置应用信息时分配的AppKey',
              key: 'JPUSH_APPKEY',
              value: '',
            },
            JPUSH_APPKEY_IOS: {
              des: '[iOS]极光portal配置应用信息时分配的AppKey',
              key: 'JCore:APP_KEY',
              value: '',
            },
            JPUSH_CHANNEL_ANDROID: {
              des: '[Android]用于统计分发渠道，不需要可填默认值developer-default',
              key: 'JPUSH_CHANNEL',
              value: '',
            },
            JPUSH_CHANNEL_IOS: {
              des: '[iOS]用于统计分发渠道，不需要可填默认值developer-default',
              key: 'JCore:CHANNEL',
              value: '',
            },
          },
        },
      },
    },
  },
  /* 快应用特有相关 */
  quickapp: {},
  /* 小程序特有相关 */
  'mp-weixin': {
    appid: VITE_WX_APPID,
    setting: {
      urlCheck: false,
    },
    usingComponents: true,
    // __usePrivacyCheck__: true,
  },
  'mp-alipay': {
    usingComponents: true,
    styleIsolation: 'shared',
  },
  'mp-baidu': {
    usingComponents: true,
  },
  'mp-toutiao': {
    usingComponents: true,
  },
  uniStatistics: {
    enable: false,
  },
  vueVersion: '3',
})
